﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using FuelTracker.Models;

namespace FuelTracker.ViewModels
{
    public class FuelLogViewModel
    {
        private FuelLog fuelLog;
        public FuelLog FuelLog
        {
            get { return fuelLog; }
        }

        public string Date
        {
            get { return fuelLog.Date.ToString("d");  }
        }

        public string Month
        {
            get { return fuelLog.Date.Month.ToString(); }
        }

        public String DistanceDriven
        {
            get
            {
                string unit = "km";
                if (fuelLog.DistanceUnit == DistanceUnit.Miles)
                    unit = "miles";

                return fuelLog.DistanceDriven.ToString("n2") + " " + unit; 
            }
          
        }

        public String AvgConsumption
        {
            get
            {
                string unit = "l";
                if (fuelLog.FuelUnit == FuelUnit.Gallons)
                    unit = "gal";
                return fuelLog.AvgConsumption.ToString("n2") + " " + unit;
            }
        }

        public FuelLogViewModel(FuelLog fuelLog)
        {
            this.fuelLog = fuelLog;
        }
    }
}
